import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class SecPage extends StatefulWidget {
  @override
  _SecPageState createState() => _SecPageState();
}

class _SecPageState extends State<SecPage> {

  BasicMessageChannel _basicMessageChannel = BasicMessageChannel("start_acticity", StandardMessageCodec());
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("SEC页面"),
      ),
      backgroundColor: Colors.white,

      ///填充布局
      body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Column(
          children: [
            ElevatedButton(
              onPressed: () {
                pop();
                //Navigator.of(context).pop();
              },
              child: Text("退出"),
            ),
            IconButton(
              icon: Icon(Icons.add),
              onPressed: () {
                //demoPlugin.invokeMethod('VueActivity');
                sendMessage();
                pop();
              },
            )
          ],
        ),
      ),
    );
  }

  static Future<void> pop() async {
    await SystemChannels.platform.invokeMethod('SystemNavigator.pop');
  }
  void sendMessage() async {
    //发送消息
    var result = await _basicMessageChannel.send("1");
    print("发送消息成功 $result");
  }
}
